class Solution {
public:
    int longestOnes(vector<int>& nums, int k) {
        int left=0;int right=0;
        int hash[2];
        int n=nums.size();
        int len=0;
        while(right<n)
        {
            hash[nums[right]]++;
            while(hash[0]>k)
            {
                hash[nums[left++]]--;
            }
            len=max(len,right-left+1);
            right++;
        }
        return len;
            }
};
